//
//  YCTitleButtonView.swift
//  swift微博
//
//  Created by 姚伟聪 on 15/12/21.
//  Copyright © 2015年 姚伟聪. All rights reserved.
//

import UIKit

class YCTitleButtonView: UIButton {

    init(title: String,titleImageName: String){
    
    super.init(frame: CGRectZero)

        
        setImage( UIImage(named: titleImageName), forState: UIControlState.Normal)
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        sizeToFit()
    
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //在布局里修改button的布局
    override func layoutSubviews() {
        
        super.layoutSubviews()
        
        titleLabel?.frame.origin.x = 0
        imageView?.frame.origin.x = (titleLabel?.frame.width)! + 5
        
    }
    
}
